<?php

namespace common\models;

use Yii;

/**
 * This is the model class for table "goodsattr".
 *
 * @property integer $ga_id
 * @property integer $g_id
 * @property integer $at_id
 *
 * @property Goods $g
 * @property ScAttr $at
 */
class Goodsattr extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'goodsattr';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['g_id', 'at_id'], 'required'],
            [['g_id', 'at_id'], 'integer']
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'ga_id' => '商品属性ID',
            'g_id' => '商品ID',
            'at_id' => '属性ID',
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getG()
    {
        return $this->hasOne(Goods::className(), ['g_id' => 'g_id']);
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getAt()
    {
        return $this->hasOne(ScAttr::className(), ['at_id' => 'at_id']);
    }
}
